using System;
using Microsoft.Practices.EnterpriseLibrary.Configuration.Design;

namespace Microsoft.Practices.Repository.Configuration.Design
{
    public sealed class RepositoryFactoryCommandRegistrar : CommandRegistrar
    {
        public RepositoryFactoryCommandRegistrar(IServiceProvider serviceProvider)
			: base(serviceProvider)
		{

		}
		
		public override void Register()
		{
            AddRepositoriesCommand();
            AddDefaultCommands(typeof(RepositoryNode));
		}

		private void AddRepositoriesCommand()
		{
            AddDefaultCommands(typeof(RepositoryFactorySectionNode));
            ConfigurationUICommand cmd = ConfigurationUICommand.CreateSingleUICommand(
                ServiceProvider,
                "Repository Factory",
                "Add Repository Factory",
                new AddRepositoryFactorySectionCommand(ServiceProvider),
                typeof(RepositoryFactorySectionNode));
            AddUICommand(cmd, typeof(ConfigurationApplicationNode));

            AddMultipleChildNodeCommand("Repository",
                "Add Repository", typeof(RepositoryNode),
                typeof(RepositoryCollectionNode));
		}
    }
}
